1 /* Copyright 2002-2016 CS Systèmes d'Information 2 * Licensed to CS Systèmes d'Information (CS) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * CS licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.orekit.propagation.semianalytical.dsst.utilities; 18 19 import java.util.TreeMap; 20 21 import org.orekit.propagation.semianalytical.dsst.utilities.CoefficientsFactory.NSKey; 22 23 /** Compute the L<sub>n</sub><sup>s</sup>(γ). 24 * <p> 25 * The fomula used is: <br> 26 * L<sub>n</sub><sup>s</sup>(γ) = ( R / a )<sup>n</sup>V<sub>ns</sub>Q<sup>ns</sup>(γ) 27 * </p> 28 * @author Lucian Barbulescu 29 */ 30 public class LnsCoefficients { 31 32 /** The coefficients L<sub>n</sub><sup>s</sup>(γ). */ 33 private final double[][] lns; 34 35 /** The coefficients dL<sub>n</sub><sup>s</sup>(γ) / dγ. */ 36 private final double[][] dlns; 37 38 /** Create a set of L<sub>n</sub><sup>s</sup>(γ) coefficients. 39 * 40 * @param nMax maximum value for n 41 * @param sMax maximum value for s 42 * @param Qns the Q<sup>ns</sup>(γ) coefficients 43 * @param Vns the V<sub>ns</sub> coefficients 44 * @param roa (R / a) 45 */ 46 public LnsCoefficients(final int nMax, final int sMax, 47 final double[][] Qns, final TreeMap<NSKey, Double> Vns, final double roa) { 48 final int rows = nMax + 1; 49 final int columns = sMax + 1; 50 this.lns = new double[rows][columns]; 51 this.dlns = new double[rows][columns]; 52 53 final double[] roaPow = new double[rows]; 54 roaPow[0] = 1.; 55 for (int i = 1; i <= nMax; i++) { 56 roaPow[i] = roa * roaPow[i - 1]; 57 } 58 for (int s = 0; s <= sMax; s++) { 59 for (int n = s; n <= nMax; n++) { 60 // if (n - s) is not even L<sub>n</sub><sup>s</sup>(γ) is 0 61 if ((n - s) % 2 == 0) { 62 final double coef = roaPow[n] * Vns.get(new NSKey(n, s)); 63 lns[n][s] = coef * Qns[n][s]; 64 if ( n == s) { 65 // if n == s the derivative is 0 because Q[n][s+1] == Q[n][n+1] is 0 66 dlns[n][s] = 0; 67 } else { 68 dlns[n][s] = coef * Qns[n][s + 1]; 69 } 70 } else { 71 lns[n][s] = 0.; 72 dlns[n][s] = 0; 73 } 74 } 75 } 76 77 } 78 79 /**Get the value of L<sub>n</sub><sup>s</sup>(γ). 80 * 81 * @param n n index 82 * @param s s index 83 * @return L<sub>n</sub><sup>s</sup>(γ) 84 */ 85 public double getLns(final int n, final int s) { 86 return lns[n][s]; 87 } 88 89 /**Get the value of dL<sub>n</sub><sup>s</sup> / dγ (γ). 90 * 91 * @param n n index 92 * @param s s index 93 * @return L<sub>n</sub><sup>s</sup>(γ) 94 */ 95 public double getdLnsdGamma(final int n, final int s) { 96 return dlns[n][s]; 97 } 98 }